//
//  TwoActvViewController.m
//  简单豆瓣不得不交版 1 带
//
//  Created by dllo on 16/6/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TwoActvViewController.h"
#import "TwoXiangQTableViewCell.h"
#import "avtviityModel.h"

static NSString *const cellTwoXq = @"CELL";

@interface TwoActvViewController ()<UITableViewDelegate, UITableViewDataSource>

@property(nonatomic, retain)UITableView *myTableView;
@property(nonatomic, retain)NSMutableArray *myArray;


@end

@implementation TwoActvViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.myArray = [NSMutableArray array];
    // Do any additional setup after loading the view.

    [self handleGata];
    [self creatTableView];

}

- (void)creatTableView {
    
    self.myTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen]bounds] style:UITableViewStylePlain];
    self.myTableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.myTableView];
    [_myTableView release];
    
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    
    [self.myTableView registerClass:[TwoXiangQTableViewCell class] forCellReuseIdentifier:cellTwoXq];
    
    
}

- (void)handleGata {
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"activitylist" ofType:@".txt"];
    NSData *data = [NSData dataWithContentsOfFile:path];
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    
    NSArray *HXArray = [dic objectForKey:@"events"];
    for (NSDictionary *dic in HXArray) {
        avtviityModel *model = [[avtviityModel alloc] init];
        [model setValuesForKeysWithDictionary:dic];
        [self.myArray addObject:model];
        
        
    }
    
    
    
    
    
    
}




- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TwoXiangQTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellTwoXq forIndexPath:indexPath];
   avtviityModel  *model = [self.myArray objectAtIndex:indexPath.row];
    cell.model = model;
    
    //  取消uitableviewcell的点以效果
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.myArray.count;
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 200;
}









- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
